import Vuex from 'vuex'
import Vue from 'vue'
import * as types from './types'
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isLogin: false,
    userData: ''
  },
  mutations: {
    [types.LOGIN]: (state, data) => {
      localStorage.setItem("isLogin","1")
      var jres = JSON.parse(data);
      localStorage.setItem("userData",jres)
      state.userData = jres
    },
    [types.LOGOUT]: (state) => {
      localStorage.setItem("isLogin","0")
      localStorage.setItem("userData",null)
      state.isLogin = false;
    },
  }
})